interface ILocalStorage<T> {
  dataType: string;
  content: T;
  dataTime: number
}
export const setStorage = <T>(key:string,content:T):void => {
  let obj:ILocalStorage<T> = {
    dataType: typeof content,
    content:content,
    dataTime:new Date().getTime()
  }
  window.localStorage.setItem(key,JSON.stringify(obj))
}
export const getStorage = <T>(key:string):T | null => {
  const value: string | null = localStorage.getItem(key)
  if (!value) return null
  const store: ILocalStorage<T> = JSON.parse(value)
  return store.content
}
export const removeStorage = (key:string):void=> {
  window.localStorage.removeItem(key)
}
export const clearStorage = ():void => {
  window.localStorage.clear()
}